var clientUrl = "http://10.138.42.215:19800/common/inter";//接口地址 定量
var clientUrl_Order = "http://10.138.42.215:19801/common/inter";//接口地址 定量

var param = {"dateDtKpi": getNowFormatDate().toString(), "dataType": "dp1169_app_anlyze_009", "fresh": "1"};//接口请求参数 变量
var params2 = {"dateDtKpi": getNowFormatDate().toString(), "dataType": "dp1169_app_anlyze_002", "fresh": "1"}//累计用户数
var params = {"dateDtKpi": getNowFormatDate().toString(), "dataType": "dp1169_app_anlyze_004", "fresh": "1"}//活跃用户活跃率
var params3 = {"dateDtKpi": getNowFormatDate().toString(), "dataType": "dp1169_app_anlyze_006", "fresh": "1"}//商品运营-订单用户数+订单用户转换率+订单额
var params4 = {"dateDtKpi": getNowFormatDate().toString(), "dataType": "dp1169_app_anlyze_007", "fresh": "1"}//商品运营-订单用户数+订单用户转换率+订单额
var params5 = {"dateDtKpi": getNowFormatDate().toString(), "dataType": "dp1169_app_anlyze_018", "fresh": "1"}//商品运营-订单用户数+订单用户转换率+订单额
var chartsArray = [];

var type = "综合";
var dataType = "";
var dataTime = getNowFormatDate().toString();
var data_LJ = ""
var data_LN = ""


$(function () {
    //显示当前时间
    var now = new Date();
    //格式化日，如果小于9，前面补0
    var day = ("0" + now.getDate()).slice(-2);
    //格式化月，如果小于9，前面补0
    var month = ("0" + (now.getMonth() + 1)).slice(-2);
    //拼装完整日期格式
    var today = now.getFullYear() + "-" + (month) + "-" + (day);
    //完成赋值
    $('#date').val(today);
    $("#date").change(function () {
        if (new Date($("#date").val()) > new Date()) {
            param.dateDtKpi = '2018';
        } else {
            param.dateDtKpi = $("#date").val();
        }
        if (new Date($("#date").val()) > new Date()) {
            params2.dateDtKpi = '2018';
        } else {
            params2.dateDtKpi = $("#date").val();
        }
        if (new Date($("#date").val()) > new Date()) {
            params3.dateDtKpi = '2018';
        } else {
            params3.dateDtKpi = $("#date").val();
        }
        if (new Date($("#date").val()) > new Date()) {
            params4.dateDtKpi = '2018';
        } else {
            params4.dateDtKpi = $("#date").val();
        }
        if (new Date($("#date").val()) > new Date()) {
            params5.dateDtKpi = '2018';
        } else {
            params5.dateDtKpi = $("#date").val();
        }

        loadCharts();
    })
    loadCharts();

});

function loadCharts() {

    loadAllData("综合");
    $(window).resize(resetCharts);
}


function loadAllData(mType){
    type=mType;
    if(type=="综合"){
        requestOrder('订单量');
        draw(name);
        shop();
        shopping(name);
        loadKeDanJia(type);
        loadCiShuAndKeHuShu(type);
        $("#ec005_hBar").attr("style","display:block;");//显示div
        $("#funnel_box").attr("style","display:none;");//隐藏div
    }else{
        $("#ec005_hBar").attr("style","display:none;");//隐藏div
        $("#funnel_box").attr("style","display:block;");//显示div
        //clear
        clearCharts();
        //alert(type);
        //list
        loadKeDanJia(type);
        shopps(type);
        draw(name);
        shop();
        shopping(name);
        requestOrder('订单量');
        loadCiShuAndKeHuShu(type);
    }


}

//请求完数据之后的回调函数  用于书写echart的独立逻辑
function getAjaxData(model) {
    console.log(model);
    console.log(model.legend);
    console.log(model.xAxis);
    console.log(model.series);

}

function loadCiShuAndKeHuShu(name) {
    var time=''
    if(new Date($("#date").val())>new Date()){
        time='2018';
    }else{
        time=$("#date").val();
    }
    var ajax1 = $.get(clientUrl_Order,{"dateDtKpi":time,"dataType":"dp1169_app_zh_gmcs_jk","fresh":"1"}).done(function(data){
        data_LN=data;
    });
    var ajax2 = $.get(clientUrl_Order,{"dateDtKpi":time,"dataType":"dp1169_app_zh_gmcs_lj","fresh":"1"}).done(function(data){
        data_LJ=data;
    });
    $.when(ajax1,ajax2).done(function(){
        var xAxis=[];
        var series_LN=[];
        var series_LJ=[];
        var series=[];
        if ('综合'==name) {
            $.each(data_LN.monthly_trend, function(index,item) {
                if(xAxis.indexOf(item.vday_ym)==-1){
                    xAxis.push(item.stat);
                }
            });
            $.each(data_LJ.monthly_trend, function(index,item) {
                if(xAxis.indexOf(item.stat)==-1){
                    xAxis.push(item.stat);
                }
            });
            xAxis.sort();
            console.log("--------------",xAxis)
            $.each(data_LN.monthly_trend,function(index,item){
                var num=xAxis.indexOf(item.stat);
                series_LN[num]=item.custnum;
            })
            $.each(data_LJ.monthly_trend,function(index,item){
                var num=xAxis.indexOf(item.stat);
                series_LJ[num]=item.custnum;
            })
        }
        console.log("&&&&&&&&&&&&&&&&&&",series_LN)
        //购买次数与客户数
        let ec005_hBar = echarts.init($("#ec005_hBar")[0]);
        ec005_hBar.clear();
        ec005_hBar.setOption(opt_line);
        ec005_hBar.setOption(opt_bar_vertical);
        ec005_hBar.setOption({
            grid: {
                top: '25%',
                bottom: '10%',
                left: '17%',
                right: '5%',
            },
            xAxis: {
                // name: '月份',
                data: xAxis,
                axisLabel:{
                    interval:0
                }
            },
            yAxis: [
                {
                    name: '客户数',
                    type:'log',
                    axisLabel: { //标签名称
                        fontSize: 12 * bodyScale
                    },
                    nameTextStyle: { //坐标轴名称
                        fontSize: 12 * bodyScale
                    },
                    nameGap: 10 * bodyScale, //坐标轴名称距离
                    axisTick: { //小刻度线
                        show: false
                    },
                    axisLine: { //坐标轴
                        lineStyle: {
                            color: cTextWeek
                        }
                    },
                    splitLine: { //分割线
                        show: false,
                        lineStyle: {
                            color: cTextWeek
                        }
                    },
                },

            ],
            series: [
                {
                    name: '乐家 ',
                    type: 'bar',
                    itemStyle: { color: colors[0] },
                    barWidth: '20%',
                    data: series_LJ,
                },
                {
                    name: '乐农 ',
                    type: 'bar',
                    itemStyle: { color: colors[1] },
                    barWidth: '20%',
                    data: series_LN,
                }
            ]
        });
        // 产品转化率
    });
}

function loadKeDanJia(name) {
    var dataType_LN = ""
    var dataType_LJ = ""
    var time = ""
    if (type == '综合') {
        dataType_LN = "dp1169_app_zh_kdj_jk";
        dataType_LJ = "dp1169_app_zh_kdj_lj";
    }
    if (type == '乐农') {
        dataType_LN = "dp1169_app_kdj_jk";
    }
    if (type == '乐家') {
        dataType_LJ = "dp1169_app_kdj_lj";
    }
    if (new Date($("#date").val()) > new Date()) {
        time = '2018';
    } else {
        time = $("#date").val();
    }
    var ajax1 = $.get(clientUrl_Order, {
        "dateDtKpi": time,
        "dataType": dataType_LN,
        "fresh": "1"
    }).done(function (data) {
        data_LN = data;
    });
    var ajax2 = $.get(clientUrl_Order, {
        "dateDtKpi": time,
        "dataType": dataType_LJ,
        "fresh": "1"
    }).done(function (data) {
        data_LJ = data;
    });
    $.when(ajax1, ajax2).done(function () {
        var yAxisArr = [];
        var series = [];
        if ('综合' == name) {
            if (data_LN.monthly_trend.length > 0) {
                if (data_LN.monthly_trend[0].chanye == '健康') {
                    yAxisArr.push('乐农');
                }
                yAxisArr.push(data_LJ.monthly_trend[0].chanye);
                if(parseInt(data_LN.monthly_trend[0].custavgamount)!=0){
                    series.push(data_LN.monthly_trend[0].custavgamount) ;
                };
                if(parseInt(data_LJ.monthly_trend[0].custavgamount)!=0){
                    series.push(data_LJ.monthly_trend[0].custavgamount) ;
                };
            }


        } else if ('乐家' == name) {
            console.log("*********************", data_LJ)
            $.each(data_LJ.monthly_trend, function (index, item) {

                if(parseInt(item.custavgamount)!=0){
                    series.push(item.custavgamount) ;
                    yAxisArr.push(item.xw_name);
                };
            });
        } else if ('乐农' == name) {
            $.each(data_LN.monthly_trend, function (index, item) {

                if(parseInt(item.custavgamount)!=0){
                    series.push(item.custavgamount) ;
                    yAxisArr.push(item.xw_name);
                };

            });
        }
        let ec003_hBar = echarts.init($("#ec003_hBar")[0]);
        ec003_hBar.clear();
        ec003_hBar.setOption(opt_bar_horizon);
        ec003_hBar.setOption({
            grid: {
                top: '5%',
                bottom: '15%',
                left: '18%',
                right: '8%',
            },
            xAxis: {
                type:'log',
                axisLabel: { //标签名称
                    fontSize: 12 * bodyScale
                },
                nameTextStyle: { //坐标轴名称
                    fontSize: 12 * bodyScale
                },
                nameGap: 10 * bodyScale, //坐标轴名称距离
                axisTick: { //小刻度线
                    show: false
                },
                axisLine: { //坐标轴
                    lineStyle: {
                        color: cTextWeek
                    }
                },
                splitLine: { //分割线
                    show: false,
                    lineStyle: {
                        color: cTextWeek
                    }
                },
            },
            yAxis: {
                data: yAxisArr
            },
            series: [
                {
                    type: 'bar',
                    value: 5,
                    itemStyle: {
                        normal: {
                            color: function (params) {
                                return colors[params.dataIndex]
                            }
                        }
                    },
                    data: series,
                }

            ]
        });
    });
}

//订单量，订单额
function requestOrder(name) {
    console.log("-----------------------------------------------------")
    if (type == '综合') {
        dataType = "dp1169_app_anlyze_zh";
    }
    if (type == '乐农') {
        dataType = "dp1169_app_anlyze_lj";
    }
    if (type == '乐家') {
        dataType = "dp1169_app_anlyze_ln";
    }
    if (type == '车小微') {
        dataType = "dp1169_app_anlyze_cxw";
    }
    if (new Date($("#date").val()) > new Date()) {
        param.dateDtKpi = '2018';

    } else {
        param.dateDtKpi = $("#date").val();

    }
    param.dataType = dataType;
    $.ajax({
        url: clientUrl_Order,
        data: param,
        // data:{"dateDtKpi":getNowFormatDate().toString(),"dataType":dataType,"fresh":"1"},
        type: 'get',
        dataType: 'json',
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //错误处理k
        },
        success: function (data) {
            if (type == "综合") {
                $("#text tbody").html("");
                var tr = [];
                var up = '';
                var down = '';
                $.each(data.monthly_trend, function (index, item) {
                    //console.log(item)
                    if (name == '订单量') {
                        var mTr = '';
                        mTr += '<tr><td>' + item.chanye + '</td><td>' + item.dayorder + '<i class="iconfont ' + judgeImage(item.dayorder) + ' "></i>'
                            + '</td><td>' + item.monthorder + '<i class="iconfont ' + judgeImage(item.monthorder) + '"></i>'
                            + '</td><td>' + parseFloat(item.yearorder).toFixed(0) + '<i class="iconfont ' + judgeImage(item.yearorder) + '"></i>'
                            + '</td><td>' + parseFloat(item.lastincrejye).toFixed(0) + '%' + '<i class="iconfont ' + judgeImage(item.lastincreorder) + '"></i></td></tr>';
                        tr.push(mTr);
                    } else if (name == '订单额') {
                        var mTr = '';
                        mTr += '<tr><td>' + item.chanye + '</td><td>' + item.dayjye + '<i class="iconfont ' + judgeImage(item.dayjye) + ' "></i>'
                            + '</td><td>' + item.monthjye + '<i class="iconfont ' + judgeImage(item.monthjye) + '"></i>'
                            + '</td><td>' + parseFloat(item.yearjye).toFixed(0) + '<i class="iconfont ' + judgeImage(item.yearjye) + '"></i>'
                            + '</td><td>' + parseFloat(item.lastincrejye).toFixed(0) + '%' + '<i class="iconfont ' + judgeImage(item.lastincrejye) + '"></i></td></tr>';
                        tr.push(mTr);
                    }
                });
                $("#text tbody").html(tr.join(''));
            }
            //console.log(data)
            else {
                $("#text tbody").html("");
                var tr = [];
                var up = '';
                var down = '';
                $.each(data.monthly_trend, function (index, item) {
                    console.log(item.dayjye + "======================")
                    //console.log(item)
                    if (name == '订单量') {
                        var mTr = '';
                        mTr += '<tr><td>' + item.xw + '</td><td>' + item.dayorder + '<i class="iconfont ' + judgeImage(item.dayorder) + ' "></i>'
                            + '</td><td>' + item.monthorder + '<i class="iconfont ' + judgeImage(item.monthorder) + '"></i>'
                            + '</td><td>' + parseFloat(item.yearorder).toFixed(0) + '<i class="iconfont ' + judgeImage(item.yearorder) + '"></i>'
                            + '</td><td>' + parseFloat(item.lastincrejye).toFixed(0) + '%' + '<i class="iconfont ' + judgeImage(item.lastincreorder) + '"></i></td></tr>';
                        tr.push(mTr);
                    } else if (name == '订单额') {
                        var mTr = '';
                        mTr += '<tr><td>' + item.xw + '</td><td>' + item.dayjye + '<i class="iconfont ' + judgeImage(item.dayjye) + ' "></i>'
                            + '</td><td>' + item.monthjye + '<i class="iconfont ' + judgeImage(item.monthjye) + '"></i>'
                            + '</td><td>' + parseFloat(item.yearjye).toFixed(0) + '<i class="iconfont ' + judgeImage(item.yearjye) + '"></i>'
                            + '</td><td>' + parseFloat(item.lastincrejye).toFixed(0) + '%' + '<i class="iconfont ' + judgeImage(item.lastincrejye) + '"></i></td></tr>';
                        tr.push(mTr);
                    }

                });
                $("#text tbody").html(tr.join(''));
            }

        }

    });
}

function requestOrder2(name) {
    if (name == '') {
        name = "dp1169_app_anlyze_009";
    }
    $.ajax({
        url: clientUrl,
        // data:param,
        data: {"dateDtKpi": getNowFormatDate().toString(), "dataType": name, "fresh": "1"},
        type: 'get',
        dataType: 'json',
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //错误处理k
        },
        success: function (data) {
            console.log(data)
            $("#text tbody").html("");
            var tr = [];
            var up = '';
            var down = '';
            $.each(data.monthly_trend, function (index, item) {
                var mTr = '';
                mTr += '<tr><td>' + item.appname + '</td><td>' + item.ecology_order_day_num + '<i class="iconfont ' + judgeImage(item.ecology_order_day_num_flag) + ' "></i>'
                    + '</td><td>' + item.ecology_order_month_num + '<i class="iconfont ' + judgeImage(item.ecology_order_month_num_flag) + '"></i>'
                    + '</td><td>' + item.ecology_order_year_num + '<i class="iconfont ' + judgeImage(item.ecology_order_year_num_flag) + '"></i>'
                    + '</td><td>' + item.rate + '<i class="iconfont ' + judgeImage(item.rate_flag) + '"></i></td></tr>';
                tr.push(mTr);

            });
            $("#text tbody").html(tr.join(''));

        }

    });
}

function judgeImage(value) {
    var num = parseFloat(value);
    if (num == 0) {
        return "icon-jiantou";
    } else if (num > 0) {
        return " icon-increase ";
    } else if (num < 0) {
        return " icon-slide ";
    }
}

//生成图例
function joinLegeng(data) {
    var legend = [];
    $.each(data.monthly_trend, function (index, item) {
        if (legend.indexOf(item.appname) == -1) {
            legend.push(item.appname);
        }
    });
    return legend;
}

//生成xAxis
function joinxAxis(data) {
    var xAxis = [];
    $.each(data.monthly_trend, function (index, item) {
        if (xAxis.indexOf(item.mon) == -1) {
            xAxis.push(item.mon);
        }
    });
    return xAxis;
}

//生成series
function joinSeries(data, legend, xAxis) {
    var series = [];
    $.each(legend, function (index, item) {
        var mSerise = {"name": item};
        var mData = Array.apply(null, Array(xAxis.length)).map(() => 0);
        var mDatas = Array.apply(null, Array(xAxis.length)).map(() => 0);
        $.each(data.monthly_trend, function (ind, it) {
            if (it.appname == item) {
                var num = xAxis.indexOf(it.mon);
                if (num != -1) {
                    mData[num] = it.new_cnt;
                    mDatas[num] = parseFloat(it.rate * 100).toFixed(2);
                }
                ;
            }
            ;
        });
        mSerise.data = mData;
        mSerise.datas = mDatas;
        series.push(mSerise);
    });

    return series;
}

//封装数据的实体
function dataModel(data) {
    var legend = joinLegeng(data);
    var xAxis = joinxAxis(data);
    this.legend = legend;
    this.xAxis = xAxis;
    this.series = joinSeries(data, legend, xAxis);
};

//记录echart对象
function recordCharts(charts) {
    if (chartsArray.indexOf(charts) == -1) {
        chartsArray.push(charts);
    }
};

//重置图表
function resetCharts() {
    $.each(chartsArray, function (index, item) {
        console.log(item)
        $(item).resize();
    })
}

function clearCharts() {
    $.each(chartsArray, function (index, item) {
        item.clear();
    })
}

//获取当前时间，格式YYYY-MM-DD
function getNowFormatDate() {
    //var date = new Date(new Date().getTime() - 86400000);
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}

function draw(name) {
    if(name==''){
        name="dp1169_app_anlyze_013";
    }
    //切换y轴的名字
    if(name=="dp1169_app_anlyze_014") {

        yaxis = {
            name: '万元'
        }
    }
    if (name == "dp1169_app_anlyze_013") {
        yaxis = {
            name: '订单量'
        }
    }

    if(new Date($("#date").val())>new Date()){
        params5.dateDtKpi='20180905';
    }else{
        params5.dateDtKpi=$("#date").val();

    }
    //alert(name);
    $.ajax({
        url: clientUrl,
        // data:params5,
        data:{"dateDtKpi":params5.dateDtKpi,"dataType":name,"fresh":"2"},
        type: 'get',
        dataType: 'json',
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //错误处理k
        },
        success: function (data) {
            var model = new dataModel(data);
            console.log(model)
            var series1 = [];
            var vlaues = [];
            $.each(model.series, function (index, item) {

                series1.push({
                    name: item.name,
                    type: 'line',
                    symbol: 'circle',
                    smooth: true,
                    lineStyle: lineStyle,
                    data: item.data
                });


            });

            let ec002_line = echarts.init($("#ec002_line")[0]);
            ec002_line.clear();
            recordCharts(ec002_line);
            ec002_line.setOption(opt_line);
            ec002_line.setOption({
                grid: {
                    top: '20%',
                    bottom: '20%',
                    left: '10%',
                    right: '4%',
                },

                xAxis: {
                    data: model.xAxis
                },
                yAxis: yaxis,
                series: series1
            });

        }

    });
}

function shop() {
    $.ajax({
        url: clientUrl,
        //data:params5,
        data:{"dateDtKpi":params5.dateDtKpi,"dataType":"dp1169_app_anlyze_018","fresh":"2"},
        type: 'get',
        dataType: 'json',
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //错误处理k
        },
        success: function (data) {
            var model = new dataModel(data);
            console.log(model)
            var series1 = [];
            var vlaues = [];
            $.each(model.series, function (index, item) {
                series1.push({
                    name: item.name,
                    type: 'line',
                    symbol: 'circle',
                    smooth: true,
                    lineStyle: lineStyle,
                    data: item.datas
                });
            });

            let ec006_line = echarts.init($("#ec006_line")[0]);
            ec006_line.clear();
            recordCharts(ec006_line);
            ec006_line.setOption(opt_line);
            ec006_line.setOption({
                grid: {
                    top: '25%',
                    bottom: '10%',
                    left: '14%',
                    right: '6%',
                },
                tooltip: {
                    position: 'top',
                    formatter: function (params) {
                        console.log(params);
                        var arr = [];
                        $.each(params, function (index, item) {
                            arr.push(params[index].seriesName + ":" + params[index].data + "%</br>");
                        });
                        return arr.join('');

                    }
                },
                legend: {
                    left: 'center',
                    orient: 'horizontal'
                },
                xAxis: {
                    // name: '月份',
                    data: model.xAxis
                },
                yAxis: {
                    name: '转化率',
                    //minInterval: 200,
                    axisLabel: {
                        formatter: '{value} %'
                    }
                },
                series: series1

            });
        }
    });


}

function shopping(name) {
    if (name == '') {
        name = "dp1169_app_anlyze_011"
    }
    if (new Date($("#date").val()) > new Date()) {
        params5.dateDtKpi = '2018';

    } else {
        params5.dateDtKpi = $("#date").val();

    }
    params5.dataType = name;
    //alert(name);
    $.ajax({
        url: clientUrl,
        //data:params5,
        data:{"dateDtKpi":params5.dateDtKpi,"dataType":name,"fresh":"2"},
        type: 'get',
        dataType: 'json',
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //错误处理k
        },
        success: function (data) {
            var model = new dataModel(data);
            console.log(model)
            var series1 = [];
            var vlaues = [];
            $.each(model.series, function (index, item) {

                series1.push({
                    value: item.data,
                    name: item.name

                });


            });

            let ec001_pie = echarts.init($("#ec001_pie")[0]);
            ec001_pie.clear();
            recordCharts(ec001_pie);
            ec001_pie.setOption(opt_pie);
            ec001_pie.setOption({
                legend: {
                    show: false,
                    data: model.legend
                },
                tooltip: {
                    trigger: 'item',
                    formatter: "{a}<br/>{b}: {c} ({d}%)"
                },
                series: [
                    {
                        name: "订单占比",
                        type: 'pie',
                        radius: ['32%', '45%'],
                        center: ['55%', '40%'],
                        avoidLabelOverlap: false,
                        label: {
                            normal: {
                                show: true,
                                fontSize: 12 * bodyScale,
                                formatter: '{b}:{c}',
                            },
                            emphasis: {
                                show: true,
                                textStyle: {
                                    fontSize: 15 * bodyScale,
                                    fontWeight: 'normal'
                                }
                            }
                        },
                        labelLine: {},
                        data: series1
                    }
                ]
            });
        }
    });


}

function shopps() {
    //alert(type)
    if(type=='乐家'){
        //alert("13342")
        if(new Date($("#date").val())>new Date()){
            params5.dateDtKpi='2018';

        }else{
            params5.dateDtKpi=$("#date").val();

        }
        $.ajax({
            url: clientUrl,
            //  data:params5,
            data:{"dateDtKpi":params5.dateDtKpi,"dataType":"dp1169_app_anlyze_027","fresh":"2"},
            type: 'get',
            dataType: 'json',
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                //错误处理k
            },
            success: function (data) {
                $("#funnel_box ul").html("");
                var tr=[];
                var up='';
                var down='';
                $.each(data.monthly_trend,function(index,item){
                    var mTr='';
                    mTr+='<li><span>'+item.new_type+'</span><span>:</span><span>'+item.new_cnt+'</span></li>';
                    tr.push(mTr);

                });
                $("#funnel_box ul").html(tr.join(''));
            }
        });

    }

    if(type=='乐农'){
        if(new Date($("#date").val())>new Date()){
            params5.dateDtKpi='2018';

        }else{
            params5.dateDtKpi=$("#date").val();

        }
        $.ajax({
            url: clientUrl,
            //data:params5,
            data:{"dateDtKpi":params5.dateDtKpi,"dataType":"dp1169_app_anlyze_031","fresh":"2"},
            type: 'get',
            dataType: 'json',
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                //错误处理
            },
            success: function (data) {
                $("#funnel_box ul").html("");
                var tr=[];
                var up='';
                var down='';
                $.each(data.monthly_trend,function(index,item){
                    var mTr='';
                    mTr+='<li><span>'+item.new_type+'</span><span>:</span><span>'+item.new_cnt+'</span></li>';
                    tr.push(mTr);

                });
                $("#funnel_box ul").html(tr.join(''));
            }
        });

    };
    if(type=='车小微'){
        clearCharts();
        $("#funnel_box ul").html("");

    }
    //alert(name);


}

